/*
 * 丰巢开门板通信协议
 * todo
 * 添加文档说明 
 */

#ifndef CFENGCHAOTRANSPORT_H_
#define CFENGCHAOTRANSPORT_H_

#include <mutex>
#include "ICommonDCBTransport.h"

namespace zl
{
namespace zlbase
{

/// \brief 丰巢开门板通信协议
class CFengchaoDCBTransport : public ICommonDCBTransport
{
public:
    CFengchaoDCBTransport() = default;
    ~CFengchaoDCBTransport() = default;

    inline std::string Version() override { return "v1.0.0"; }

    inline int32_t OpenLocker(int32_t col, int32_t index) override
	{
		return cmd_openlocker(col, index);
	}

	inline int32_t GetDoorStatus(int32_t col, unsigned char* status, size_t& len) override
	{
		return cmd_getdoorstatus(col, status, len);
	}

	inline int32_t GetItemStatus(int32_t col, unsigned char* status, size_t& len) override
	{
		return cmd_getitemstatus(col, status, len);
	}

	inline int32_t GetFirmwareVersion(int32_t col, unsigned char* version, size_t& len) override
	{
		return cmd_getfirmwareversion(col, version, len);
	}

protected:
	int32_t cmd_openlocker(int32_t col, int32_t index);
	int32_t cmd_getdoorstatus(int32_t col, unsigned char* status, size_t& len);
	int32_t cmd_getitemstatus(int32_t col, unsigned char* status, size_t& len);
	int32_t cmd_getfirmwareversion(int32_t col, unsigned char* version, size_t& len);
};

} // namespace zlbase
} // namespace zl

#endif // CFENGCHAOTRANSPORT_H_
